<%--
  Created by IntelliJ IDEA.
  User: 10171225
  Date: 2016/6/20
  Time: 17:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>"/>
    <title>创建公告</title>
    <script src="static/javascript/jquery-1.11.3.min.js"></script>
    <script src="static/javascript/utils.js"></script>
    <script src="static/javascript/base.js"></script>

    <script type="text/javascript" src="plugins/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="plugins/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" language="JavaScript">
        $(document).ready(function(){
            var editor = new UE.ui.Editor();
            editor.render('container');

            $("#createNotice").click(function () {
                var map = {
                    "公告标题": $("#title")
                }
                if($.judgeNotNull(map) == false){
                    return false;
                }
                if("" == $.trim(editor.getContent())) {
                    alert("正文不可以为空！");
                    editor.focus();
                    return false;
                }
                $.ajax({
                    type : 'get',
                    contentType:"application/json;charset=utf-8",
                    url : 'admin/editManage/noticeCreate',
                    dataType : 'json',
                    cache: false,
                    timeout: 5000,
                    async: false,
                    data: {
                        "title" : encodeURI($("#title").val()),
                        "content": encodeURI(editor.getContent()),
                        "tag": encodeURI($("#tag").val())
                    },
                    success: function(result){
                        alert(result);
                        $("#editNoticeManage").click();
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert("ajax异常，请联系管理员！");
                    }
                });
            });
        });
    </script>
</head>
<body>
<div>
    <span>公告标题：</span>
    <input type="text" id="title" name="title" size="20em"/><br/>
    <span>公告内容：</span>
    <script id="container" name="content" type="text/plain">
    </script>
    <button name="submit"  id="createNotice">提交</button>
</div>
</body>
</html>